package com.example.administrator.zdtumblr_android_new.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.zdtumblr_android_new.PlayActivity;
import com.example.administrator.zdtumblr_android_new.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/24 0024.
 */

public class MainRecycleItemAdapter extends RecyclerView.Adapter<MainRecycleItemViewHolder> {

    private LayoutInflater inflater;
    private Context mContext;

    public MainRecycleItemAdapter(Context mContext) {
        this.inflater = LayoutInflater.from(mContext);
        this.mContext = mContext;
    }

    @Override
    public MainRecycleItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MainRecycleItemViewHolder holder = new MainRecycleItemViewHolder(inflater.inflate(R.layout.adapter_main_recycle_footer_item_view, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MainRecycleItemViewHolder holder, final int position) {
        holder.img1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, PlayActivity.class);
                intent.putExtra("index",0);
                mContext.startActivity(intent);
            }
        });

        holder.img2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, PlayActivity.class);
                intent.putExtra("index",1);
                mContext.startActivity(intent);
            }
        });

        holder.img3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, PlayActivity.class);
                intent.putExtra("index",2);
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 10;
    }
}

class MainRecycleItemViewHolder extends RecyclerView.ViewHolder {
    @Bind(R.id.foot_item_view_name)
    TextView footItemViewName;
    @Bind(R.id.img1)
    ImageView img1;
    @Bind(R.id.img2)
    ImageView img2;
    @Bind(R.id.img3)
    ImageView img3;
    @Bind(R.id.conner_img)
    ImageView connerImg;
    public MainRecycleItemViewHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this,itemView);
    }
}